import java.util.Calendar;
import java.util.Random;

/**
 * @autor my
 * 2017/8/23.
 */
public class RandomDate {
    //借助随机数，创建一个从1995.1.1 00:00:00 到 2005.12.31 23:59:59 之间的随机日期并打印输出
    public static void main(String[] args) {
        Calendar calendar=Calendar.getInstance();
        Random random =new Random();
        int year=random.nextInt(10)+1995;
        int month=random.nextInt(12)+1;
        int day=1;
        //判断每月随机的范围
        if (month==1||month==3||month==5||month==7||month==8||month==10||month==12){
            day=random.nextInt(31)+1;
        }
        else if (month==4||month==6||month==9||month==11){
            day=random.nextInt(30)+1;
        }
        else {
            //判断二月有多少天
            if (year%4==0){
                day=random.nextInt(29)+1;
            }
            else {
                day=random.nextInt(28)+1;
            }

        }
        int hour=random.nextInt(24);
        int minute=random.nextInt(60);
        int second=random.nextInt(60);
        //打印结果
        System.out.println(year+"."+month+"."+day+"   "+hour+"："+minute+"："+second);
    }
}
